/*
 * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: Unlicense OR CC0-1.0
 */
#pragma once


// 0x00 ~ 0xff   blink 1 time ~ 256 times to refresh
#define SSD1681_WAVESHARE_1IN54_REFRESH_TIME           0x01
#define SSD1681_WAVESHARE_1IN54_V2_LUT_FULL_REFRESH ((uint8_t[]) { \
        /* LUT 0 VS Group 0~11 */ \
        0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 1 VS Group 0~11 */ \
        0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 2 VS Group 0~11, keep the same as LUT0 for Black-White e-Paper */ \
        0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 3 VS Group 0~11, keep the same as LUT1 for Black-White e-Paper */ \
        0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 4 VS Group 0~11, seems useless, just keep all zero */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* --- */ \
        /* Only Group0~2 are used */ \
        /* Group 0  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 1  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0xA, 0x2, 0x0, 0xA, 0x2, 0x0, SSD1681_WAVESHARE_1IN54_REFRESH_TIME, \
        /* Group 2  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 3  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 4  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 5  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 6  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 7  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 8  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 9  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 10 TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 11 TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* --- */ \
        0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0, \
        /* --- Other register params, do not transfer together with data above */ \
        0x22, 0x17, 0x41, 0x0, 0x32, 0x20 \
})

#define SSD1681_WAVESHARE_1IN54_V2_LUT_FAST_REFRESH ((uint8_t[]) { \
        /* LUT 0 VS Group 0~11 */ \
        0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 1 VS Group 0~11 */ \
        0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 2 VS Group 0~11, keep the same as LUT0 for Black-White e-Paper */ \
        0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 3 VS Group 0~11, keep the same as LUT1 for Black-White e-Paper */ \
        0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 4 VS Group 0~11, seems useless, just keep all zero */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* --- */ \
        /* Only Group0~2 are used */ \
        /* Group 0  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 1  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 2  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 3  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 4  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 5  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 6  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 7  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 8  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 9  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 10 TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 11 TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* --- */ \
        0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0, \
        /* --- Other register params, do not transfer together with data above */ \
        0x22, 0x17, 0x41, 0x0, 0x32, 0x20 \
})

// NOTE: After several refreshes using SSD1681_WAVESHARE_1IN54_V2_LUT_FAST_REFRESH, you may notice the WHITE color
// goes GRAY and contrast decrease a lot. Use the LUT below to avoid that issue.
// NOTE: The LUT below will have the source output "keep previous output before power off", so the service life may be affected.
#define SSD1681_WAVESHARE_1IN54_V2_LUT_FAST_REFRESH_KEEP ((uint8_t[]) { \
        /* LUT 0 VS Group 0~11 */ \
        0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 1 VS Group 0~11 */ \
        0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 2 VS Group 0~11, keep the same as LUT0 for Black-White e-Paper */ \
        0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 3 VS Group 0~11, keep the same as LUT1 for Black-White e-Paper */ \
        0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* LUT 4 VS Group 0~11, seems useless, just keep all zero */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* --- */ \
        /* Only Group0~2 are used */ \
        /* Group 0  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 1  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 2  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 3  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 4  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 5  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 6  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 7  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 8  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 9  TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 10 TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* Group 11 TP[*A] TP[*B] SR[*AB] TP[*C] TP[*D] SR[*CD] RP[*] */ \
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
        /* --- */ \
        0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0, \
        /* --- Other register params, do not transfer together with data above */ \
        0x07, 0x17, 0x41, 0x0, 0x32, 0x20 \
})
